//package baseFx.common.mq.rabbitmq;
//
//import com.rabbitmq.client.ConnectionFactory;
//import org.apache.commons.pool2.BasePooledObjectFactory;
//import org.apache.commons.pool2.PooledObject;
//import org.apache.commons.pool2.impl.DefaultPooledObject;
//
//public class ConnectionPOFactory extends BasePooledObjectFactory<MqConnection> {
//    private ConnectionFactory factory;
//    private PoolConfig config;
//    private RabbitMqContext context;
//
//    public ConnectionPOFactory(ConnectionFactory factory, RabbitMqContext context, PoolConfig config) {
//        this.factory = factory;
//        this.config = config;
//        this.context = context;
//    }
//
//    @Override
//    public MqConnection create() throws Exception {
//        return new MqConnection(factory.newConnection(), context, config);
//    }
//
//    @Override
//    public PooledObject<MqConnection> wrap(MqConnection connection) {
//        return new DefaultPooledObject<>(connection);
//    }
//
//    @Override
//    public void destroyObject(PooledObject<MqConnection> p) throws Exception {
//        p.getObject().destroy();
//    }
//
//    @Override
//    public boolean validateObject(PooledObject<MqConnection> p) {
//        return p.getObject().isOpen();
//    }
//}
